package com.springcloud.log.modular.log.controller;

import com.springcloud.commom.annotion.BusinessLog;
import com.springcloud.commom.enums.LogAnnotionOpTypeEnum;
import com.springcloud.commom.api.R;

import com.springcloud.log.modular.log.service.SysOpLogService;
import com.springcloud.log.param.OpLogParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;

/**
 * 系统操作日志表控制器
 *
 * @author hzl
 * @date 2024-07-23 09:58:00
 */
@RestController
public class SysOpLogController {

    @Resource
    private SysOpLogService sysOpLogService;

    /**
     * 查询系统操作日志表
     *
     * @author hzl
     * @date 2024-07-23 09:58:00
     */
    @GetMapping("/opLog/page")
    @BusinessLog(title = "系统操作日志表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public R page(OpLogParam opLogParam) {
        return R.data(sysOpLogService.page(opLogParam));
    }

    /**
     * 添加系统操作日志表
     *
     * @author hzl
     * @date 2024-07-23 09:58:00
     */
    @PostMapping("/opLog/add")
    @BusinessLog(title = "系统操作日志表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public R add(@RequestBody @Validated(OpLogParam.add.class) OpLogParam opLogParam) {
            sysOpLogService.add(opLogParam);
        return R.success();
    }

    /**
     * 删除系统操作日志表
     *
     * @author hzl
     * @date 2024-07-23 09:58:00
     */
    @PostMapping("/opLog/delete")
    @BusinessLog(title = "系统操作日志表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public R delete(@RequestBody @Validated(OpLogParam.delete.class) OpLogParam opLogParam) {
            sysOpLogService.delete(opLogParam);
        return R.success();
    }

    /**
     * 编辑系统操作日志表
     *
     * @author hzl
     * @date 2024-07-23 09:58:00
     */
    @PostMapping("/opLog/edit")
    @BusinessLog(title = "系统操作日志表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public R edit(@RequestBody @Validated(OpLogParam.edit.class) OpLogParam opLogParam) {
            sysOpLogService.edit(opLogParam);
        return R.success();
    }

    /**
     * 查看系统操作日志表
     *
     * @author hzl
     * @date 2024-07-23 09:58:00
     */
    @GetMapping("/opLog/detail")
    @BusinessLog(title = "系统操作日志表_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public R detail(@Validated(OpLogParam.detail.class) OpLogParam opLogParam) {
        return R.data(sysOpLogService.detail(opLogParam));
    }

    /**
     * 系统操作日志表列表
     *
     * @author hzl
     * @date 2024-07-23 09:58:00
     */
    @GetMapping("/opLog/list")
    @BusinessLog(title = "系统操作日志表_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public R list(OpLogParam opLogParam) {
        return R.data(sysOpLogService.list(opLogParam));
    }

}
